#ifndef PICAJSONRPCC_H_
#define PICAJSONRPCC_H_

#include <ev.h>

extern struct timeval lastStartTimestamp;
extern bool pica_stat_sync_requested;
extern bool pica_stat_write_file_flag;

struct jrpc_server {
    int port_number;
    struct ev_loop *loop;
    ev_io listen_watcher;
    int debug_level;
    unsigned int con_number;
};

struct jrpc_connection {
    struct ev_io io;
    int fd;
    unsigned int pos;
    unsigned int buffer_size;
    char * buffer;
    int debug_level;
};

void pica_jrpc_server_create_thread();

int pica_jrpc_server_init();

int pica_jrpc_server_init_with_ev_loop(struct jrpc_server *server,
                                       int port_number, struct ev_loop *loop);

static int pica_jrpc_server_start(struct jrpc_server *server);

void pica_jrpc_server_run(struct jrpc_server *server);

int pica_jrpc_server_stop(struct jrpc_server *server);

#endif
